<!DOCTYPE html>
<html lang="en">
<title>Ανακοινώσεις</title>
<body>
<script>
    function generateGeneralAnnouncementsTable(title,date,author,content,group,time) {
        var table = document.getElementById("announcementsTableGeneral");
        var row = table.insertRow(table.rows.length);



        if (group == "Γενικές ανακοινώσεις")
        {
            var titleCell = row.insertCell(0);
            var dateCell = row.insertCell(1);
            var authorCell = row.insertCell(2);
            titleCell.innerHTML = '<input class="btn btn-default btn-lg" type="Submit" value=\''+title+'\' onClick="showAnnouncementContent(\'' + content + '\')" />';
            dateCell.innerHTML = date+"  -  "+time;
            authorCell.innerHTML = author;
        }
    }
    function generateGroupAnnouncementsTable(title,date,author,content,group,userGroup,time) {
        var table = document.getElementById("announcementsTableGroup");
        var row = table.insertRow(table.rows.length);

        if (group == userGroup)
        {
            var titleCell = row.insertCell(0);
            var dateCell = row.insertCell(1);
            var authorCell = row.insertCell(2);
            titleCell.innerHTML = '<input class="btn btn-default btn-lg" type="Submit" value=\''+title+'\' onClick="showAnnouncementContentGroup(\'' + content + '\')" />';
            dateCell.innerHTML = date+"  -  "+time;
            authorCell.innerHTML = author;
        }
    }
    function showAnnouncementContent(content)
    {
        document.getElementById("announcementContent").value = content;
    }function showAnnouncementContentGroup(content)
    {
        document.getElementById("announcementContentGroup").value = content;
    }

</script>
<!-- Header -->
<a name="about"></a>
<div class="intro-headerlogin" style="height: px"></div>
<!-- /.content-section-a -->
<div class="content-section-b">
    <div class="container">
        <div class="row">
            <hr class="section-heading-spacer">
            <div class="clearfix"></div>
            <h1>Ανακοινώσεις</h1><br>
            <div class="tabs">
                <ul class="tab-links">
                    <li class="active"><a href="#generalAnnouncements">Γενικές Ανακοινώσεις</a></li>
                    <li>
                            <?php
                            if($this->session->userdata('group'))
                            {
                                echo '<a href="#groupAnnouncements">';
                                echo $this->session->userdata('group');
                            }
                            ?></a></li>

                </ul>
                <div class="tab-content">
                    <div id="generalAnnouncements" class="tab active">

                        <table id="announcementsTableGeneral" style="width:100%; float:left;margin-bottom: 10px">
                            <tr style="float:center">
                                <th>Τίτλος ανακοίνωσης</th>
                                <th>Ημερομηνία - Ώρα</th>
                                <th>Εκδότης</th>
                            </tr>
                        </table><br>
                        <textarea readonly id="announcementContent" rows="10" cols="50" style="float:left;width: 100%;margin-top:5px; font-size: 20px;padding: 10px;" placeholder="Κάντε κλικ σε κάποια απο τις παραπάνω ανακοινώσεις για να εμφανιστεί εδώ"></textarea>
                        <?php
                            $i=0;
                            foreach ($results as $row)
                            {

                                echo '<script type="text/javascript">'
                                , 'generateGeneralAnnouncementsTable("'.$results[$i]->title.'","'.$results[$i]->date.'","'.$results[$i]->author.'","'.$results[$i]->content.'","'.$results[$i]->category.'","'.$results[$i]->time.'");'
                                , '</script>';
                                $i++;
                            }
                        ?>

                    </div>

                    <div id="groupAnnouncements" class="tab">
                        <table id="announcementsTableGroup" style="width:100%; float:left;margin-bottom: 10px">
                            <tr style="float:center">
                                <th>Τίτλος ανακοίνωσης</td>
                                <th>Ημερομηνία - Ώρα</td>
                                <th>Εκδότης</td>
                            </tr>
                        </table><br>
                        <textarea readonly id="announcementContentGroup" rows="10" cols="50" style="float:left;width: 100%;margin-top:5px; font-size: 20px;padding: 10px;">Κάντε κλίκ σε κάποια ανακοίνωση απο επάνω για να εμφανιστεί εδώ
                        </textarea>
                        <?php
                        $i=0;
                        foreach ($results as $row)
                        {
                            $userGroup = $this->session->userdata('group');
                            echo '<script type="text/javascript">'
                            , 'generateGroupAnnouncementsTable("'.$results[$i]->title.'","'.$results[$i]->date.'","'.$results[$i]->author.'","'.$results[$i]->content.'","'.$results[$i]->category.'","'.$userGroup.'","'.$results[$i]->time.'");'
                            , '</script>';
                            $i++;
                        }
                        ?>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- /.container -->

</div>

</body>
